'''
Created on Mar 14, 2011

@author: srikanth_nukala
'''
from com.sai.Settings import behindProxy
import base64
import sys
import urllib2


def getPage(url,proxy_str):
    if behindProxy:
        proxy = urllib2.ProxyHandler({'http': proxy_str})
        auth = urllib2.HTTPBasicAuthHandler()
        opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
        urllib2.install_opener(opener)  
    try:  
        headers = { 'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' }
        req = urllib2.Request(url, '', headers)
        conn = urllib2.urlopen(url)
        return_str = conn.read()
    except Exception,e:
        sys.stdout.write("%s" % e)
        return_str = "EXCEPTION"    
    return return_str    
    